/*
 * Copyright (c) 2020, 2025, keyila All rights reserved.
 *
 */
package com.clp.study.controller;

import com.clp.util.RedisShareLockUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author clp
 * @version 1.0
 */
@RestController
@Slf4j
public class TestController {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RedisShareLockUtil redisShareLockUtil;

    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }

    @GetMapping("testRedis")
    public void testRedis(){
        redisTemplate.opsForValue().set("name","陈立鹏");
    }

    @GetMapping("testShareLockRedis")
    public void testShareLockRedis(){
        boolean lock = redisShareLockUtil.lock("222", "22222", 100000L);
        System.out.println(lock);
    }

    @GetMapping("testLog")
    public void testLog(){
        long startTime=System.currentTimeMillis();
        for (int i = 0; i <10000 ; i++) {
            log.info("这是第{}条日志",i);
        }
        long endTime=System.currentTimeMillis();
        log.info("总共耗时{}",endTime-startTime);
    }

}
